package com.wrong.desgin.redis.cluster;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author: hliushi
 * @date: 2022/12/5 22:46
 **/
@Slf4j
public class EGM {

    private final Map<String, Object> dataMap = Maps.newConcurrentMap();

    public Object gain(String key) {
        log.info(">>> EGM redis cluster get data key: {}", key);
        return dataMap.get(key);
    }

    public void set(String key, Object value) {
        log.info(">>> EGM redis cluster set data key: {}, value: {}", key, value);
        dataMap.put(key, value);
    }

    public void setEx(String key, Object value, long timeout, TimeUnit unit) {
        log.info(">>> EGM redis cluster set timeout data. time: {} key: {}, value: {}", timeout, key, value);
        dataMap.put(key, value);
    }

    public void delete(String key) {
        log.info(">>> EGM redis cluster remove data key: {}", key);
        dataMap.remove(key);
    }

}
